/**
 * @param {string} s
 * @return {number}
 * 
 */
console.log(romanToInt('LVIII'));

function romanToInt(s) {
    var hashtable = { I: 1, V: 5, X: 10, L: 50, C: 100, D: 500, M: 1000 };
    var s2 = 0;
    for (let i = 0; i < s.length; i++) {
        if (hashtable[s.charAt(i)] < hashtable[s.charAt(i + 1)]) {
            s2 += -hashtable[s.charAt(i)];
        } else { s2 += hashtable[s.charAt(i)]; }
    }
    return s2;
};